package wowraidmanager.client.wishlist.wishlist;

import java.util.ArrayList;

import wowraidmanager.client.service.wishlist.RaidbossDroplistService;
import wowraidmanager.client.service.wishlist.RaidbossDroplistServiceAsync;
import wowraidmanager.client.wishlist.utils.RaidbossDroplistUtil;
import wowraidmanager.shared.model.wishlist.Member;
import wowraidmanager.shared.model.wishlist.RaidbossDroplist;
import wowraidmanager.shared.model.wishlist.UserStatus;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.TabPanel;
import com.google.gwt.user.client.ui.Widget;

public class EditwishlistRaidzone extends Composite{

    private static EditwishlistRaidzoneUiBinder uiBinder = GWT.create(EditwishlistRaidzoneUiBinder.class);

    protected RaidbossDroplistServiceAsync raidbossDroplistService = GWT.create(RaidbossDroplistService.class);

    interface EditwishlistRaidzoneUiBinder extends UiBinder<Widget, EditwishlistRaidzone>{
    }

    String gameVersion;

    UserStatus userStatus;

    ArrayList<RaidbossDroplist> raidzonedroplist;

    Member currentMember;

    @UiField
    TabPanel raidzoneTab;

    public EditwishlistRaidzone(String gameVersion, UserStatus userStatus, ArrayList<RaidbossDroplist> raidbossdroplist, Member currentMember){
        initWidget(uiBinder.createAndBindUi(this));
        this.gameVersion = gameVersion;
        this.userStatus = userStatus;
        this.raidzonedroplist = raidbossdroplist;
        this.currentMember = currentMember;

        setTabPanel();
    }

    private void setTabPanel(){
        ArrayList<String> raidzoneList = RaidbossDroplistUtil.getRaidzone(raidzonedroplist);
        for(String raidzone:raidzoneList){
            ArrayList<RaidbossDroplist> newRaidzoneDroplist = RaidbossDroplistUtil.getRaidbossdroplistRaidzone(raidzonedroplist, raidzone);
            raidzoneTab.add(new EditwishlistBossInfo(raidzone, userStatus, newRaidzoneDroplist, currentMember), raidzone);
        }
        raidzoneTab.selectTab(0);
    }

}
